interface MsgProps {
	name: string
	mgs: string
}
export class WXSocket {
	list: MsgProps[] = []
	ws: any
	constructor() {	}
	init(callback=()=>{}) {
		this.ws = wx.connectSocket({
			// url: 'ws://web.uat.szctjt.cn/api/mall//ws/signUp',
			url:'ws://10.11.171.1:20001/api/mall/ws/signUp',
			success: (res: any) => {
				console.log('WebSocket连接成功', res)
				callback()
			},
			fail: (res: any) => {
				console.log('WebSocket连接失败', res)
			}
		})
	}
	//关闭 WebSocket 连接
	close() {
		this.ws.close({
			success: (res: any) => {
				console.log('WebSocket关闭成功', res)
			},
			fail: (res: any) => {
				console.log('WebSocket关闭失败', res)
			}
		})
	}
	//监听 WebSocket 连接打开事件
	onOpen() {
		
	}
	//监听 WebSocket 接收到服务器的消息事件
	onMessage() {
		this.ws.onMessage((res: any) => {
			console.log('接收到服务器的消息事件', res)
		})
	}
	//通过 WebSocket 发送数据
	send() {
		this.ws.send({
			data: '通过 WebSocket 发送数据',//string/ArrayBuffer
			success: (res: any) => {
				console.log('发送数据成功', res)
			},
			fail: (res: any) => {
				console.log('发送数据失败', res)
			}
		})
	}
}